<?php
/**
 * Created by PhpStorm.
 * User: 盛茂国
 * Tel: 18394333958
 * Date: 2020/6/2
 * Time: 10:31
 */
namespace app\api\controller;


use app\common\controller\Api;
use think\Cache;
use think\Request;

class Bugword extends Api
{
    protected $noNeedLogin=['index'];
    protected $noNeedRight=[];
    public function index(Request $request){
//        Cache::set('name',$value,3600);
        $words=Cache::get('words');
        if($words){
            return json(['code'=>200,'msg'=>'成功获取违禁词','data'=>$words]);
        }else{
            $words=db('bugword')->select();
            if($words){
                Cache::set('words',$words);
                return json(['code'=>200,'msg'=>'成功获取违禁词','data'=>$words]);
            }else{
                return json(['code'=>400,'msg'=>'数据库中还没有违禁词词库','data'=>$words]);
            }
        }
    }
}